import defineReactive from './defineReactive';
import { arrayMethods } from './array';
import observe from './observe';
import def from './def';
// import Dep from './Dep';
export default class Observer {
    constructor (value) {
        def(value, "__ob__", this, false);
        // this.dep = new Dep();
        if (Array.isArray(value)) {
            // 数组的方法
            Object.setPrototypeOf(value, arrayMethods);
            this.observeArray(value);
        } else {
            this.walk(value);
        }
    }

    walk (value) {
        // Object.keys(value).forEach((key, index) => {
        //     defineReactive
        // });
        for (let key in value) {
            defineReactive(value, key);
        }
    }

    observeArray (arr) {
        // value.forEach(item => observe(item));
        for (let i = 0; i < arr.length; i++) {
            observe(arr[i]);
        }
    }
};
